package com.qianfeng.web.servlet;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.qianfeng.biz.IGoodsInfoBiz;
import com.qianfeng.biz.IGoodsTypeBiz;
import com.qianfeng.biz.impl.GoodsInfoBizImpl;
import com.qianfeng.biz.impl.GoodsTypeBizImpl;
import com.qianfeng.entity.GoodInfo;
import com.qianfeng.entity.GoodType;


public class InitServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
	private IGoodsTypeBiz gtBiz = new GoodsTypeBizImpl();
	private IGoodsInfoBiz giBiz = new GoodsInfoBizImpl();
  
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doPost(request, response);
	}


	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		String action = request.getParameter("action");
		if("queryAll".equals(action)){
			//1.得到所有的商品类别信息
			//2.得到所有的商品信息
			List<GoodInfo> giList = giBiz.queryAllGoodsInfo();
			List<GoodType> gtList = gtBiz.queryAllGoodsType();
			
			
			request.setAttribute("gtList", gtList);
			request.setAttribute("giList", giList);
			request.getRequestDispatcher("index.jsp").forward(request, response);
			
		}
	}

}
